namespace MSP.Graph
{
    public class Edge
    {
        #region Properties

        private IDisCOPNode m_node1;
        public IDisCOPNode Node1
        {
            get { return m_node1; }
            set { m_node1 = value; }
        }

        private IDisCOPNode m_node2;
        public IDisCOPNode Node2
        {
            get { return m_node2; }
            set { m_node2 = value; }
        }

        private object m_data;
        public object Data
        {
            get { return m_data; }
            set { m_data = value; }
        }

        #endregion  // Properties

        #region Constructor

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="node1 - The first node"></param>
        /// <param name="node2 - The second node"></param>
        /// <param name="data - The data of the edge"></param>
        public Edge(IDisCOPNode node1, IDisCOPNode node2, object data)
        {
            m_node1 = node1;
            m_node2 = node2;
            m_data = data;
        }

        #endregion  // Constructor


        #region Functions

        /// <summary>
        /// Return the other node that is connect with the edge
        /// </summary>
        /// <param name="node - The node that seeks its neighbor"></param>
        /// <returns>The other node which is connected with the edge</returns>
        public IDisCOPNode GetNeighbor(IDisCOPNode node)
        {
            // return the other node that is connect with the edge
            return m_node1.Equals(node) ? m_node2 : m_node1;
        }

        #endregion  // Functions
    }
}
